<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>model demo</title>
    <style>
        *{
            margin: 0;
        }
        #sign_up{
            background-color: lightseagreen;
            cursor:pointer;
        }
        #close{
            cursor: pointer;
            font-size: 3em;
            font-weight: bolder;
        }
        #modal{
            display: none;
            position: fixed;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            background: rgba(0,0,0,60%);
        }
        #content{
            background: #fff;
            margin: 20% auto;
            width: 300px;
            height: 100px;
            padding: 20px;
        }
    </style>
</head>
<body>
    <h1>子窗口</h1>
    <span id="sign_up">注册</span>
    <div id="modal">
        <div id="content">
            <span id="close">&times;</span>
            <p>内容</p>
        </div>
    </div>
</body>
<script>
    const signUp = document.getElementById('sign_up');
    const modal = document.getElementById('modal');
    const close = document.getElementById('close');
    signUp.onclick = function (){
        modal.style.display='block';
    }
    close.onclick=function (){
        modal.style.display='none';
    }
    window.onclick=function (event){
        if(event.target==modal){
            modal.style.display='none';
        }
    }
</script>
</html>